Using macro to check null values [migrated]

Posted by poliron on Programmers See other posts from Programmers or by poliron
Published on 2012-04-08T19:09:47Z Indexed on 2012/04/08 23:46 UTC
Read the original article Hit count: 146

Filed under:
|
|

My C code contains many functions with pointers to different structs as parameteres which shouldn't be NULL pointers. To make my code more readable, I decided to replace this code:

if(arg1==NULL || arg2==NULL || arg3==NULL...) { return SOME_ERROR; }

With that macro: NULL_CHECK(arg1,arg2,...)

How should I write it, if the number of args is unknown and they can point to different structs?(I work in C99)

© Programmers or respective owner

Related posts about c

    Related posts about code-quality